package com.imachen.order.rocket.impl;

import com.imachen.order.service.IOrderPetAcquisitionService;
import io.netty.util.CharsetUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RocketMQMessageListener(topic = "order-topic",selectorExpression="*",consumerGroup = "queue_group_test")
public class RocketMQMsgListener implements RocketMQListener<MessageExt> {

    @Autowired
    private IOrderPetAcquisitionService orderPetAcquisitionService;

    @Override
    public void onMessage(MessageExt message) {
        byte[] body = message.getBody();
        String msg = new String(body, CharsetUtil.UTF_8);
        orderPetAcquisitionService.cancel(Long.valueOf(msg));
        log.info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"+msg);
    }

}